//
//  SCDemoViewController.m
//  shareDemo
//
//  Created by MiYa-ShaoCong on 2017/6/13.
//  Copyright © 2017年 Nice. All rights reserved.
//

#import "SCDemoViewController.h"
#import "ViewController.h"
#import "HomeVC.h"
#import <WebKit/WebKit.h>

@interface SCDemoViewController ()

@end

@implementation SCDemoViewController

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    // 禁用返回手势
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.backKuang setHidden:YES];
    [self showBackCenterKuang:[UIImage imageNamed:@"back_center"]];
    self.title = self.titleStr;
    [self.titleView.backBtn addTarget:self action:@selector(onClickedOKbtn) forControlEvents:UIControlEventTouchUpInside];
    //加载数据
    [self loadRequest];
}

-(void)loadRequest{
    WKWebView *webView = [[WKWebView alloc]init];
    webView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:webView];
    [webView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.view).multipliedBy(0.8);
        make.height.equalTo(self.view).multipliedBy(0.7);
        make.centerX.equalTo(self.view.mas_centerX);
        make.centerY.equalTo(self.view.mas_centerY).offset(20);
    }];
//    webView.opaque = NO;
//    webView.backgroundColor = UIColor.clearColor;
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",self.url]]]];

}

- (void)onClickedOKbtn {
    if (NSUDGetToken) {
        AppDelegate *appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
        HomeVC *login = [[HomeVC alloc]initWithNibName:@"HomeVC" bundle:nil];
        BaseNavVC *navLogin = [[BaseNavVC alloc] initWithRootViewController:login];
        appDelegate.window.rootViewController = navLogin;
        
    }else{
        AppDelegate *appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
        LoginVC *login = [[LoginVC alloc]initWithNibName:@"LoginVC" bundle:nil];
        BaseNavVC *navLogin = [[BaseNavVC alloc] initWithRootViewController:login];
        appDelegate.window.rootViewController = navLogin;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
